package org.wlw.extend;

public class TestPoly {
	public static void main(String[] args) {
		//多态特性的是父类的对象(引用)指向子类对象
		Student stu = new MiddleStudent("小明");
		stu.study();
//		stu.age = 20;//因为stu是父类对象，并没有子类的age属性
		//对象能够进行强制类型转换的前提是父类的引用指向了子类的对象
		MiddleStudent ms = (MiddleStudent)stu;
		ms.age = 22;
		System.out.println(ms.name+","+ms.age);
		System.out.println(((MiddleStudent)stu).age);
		//对象的强制类型转换只能用在多态之中
		Cat c = new Cat();
//		Student s = (Student)c;
	}
}
